package pct.manage;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import pct.database.PcServiceImpl;

public class TimerListener implements ServletContextListener{
	private Timer timer=null;
	private Task task;
	private PcServiceImpl pcService = new PcServiceImpl();
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		timer.cancel();
		event.getServletContext().log("timer is killed");
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		timer=new Timer(true);
		event.getServletContext().log("timer is running");
		timer.schedule(new Task(),0,1000);//24*60*60*1000
		event.getServletContext().log("work is done");
	}

}
